// 为所有页面添加一个navigateTo方法
export default {
  Page: {
    navigateTo(e) {
      const { url } = e.currentTarget.dataset;
      wx.navigateTo({ url });
    },
    navigateBack(e) {
      const { delta } = e.currentTarget.dataset;
      wx.navigateBack({ delta });
    },
    redirectTo(e) {
      const { url } = e.currentTarget.dataset;
      wx.redirectTo({ url });
    },
    switchTab(e) {
      const { url } = e.currentTarget.dataset;
      wx.switchTab({ url });
    }
  },
  //Component Object
  Component: {
    methods: {
      navigateTo(e) {
        const { url } = e.currentTarget.dataset;
        wx.navigateTo({ url });
      },
      navigateBack(e) {
        const { delta } = e.currentTarget.dataset;
        wx.navigateBack({ delta });
      },
      redirectTo(e) {
        const { url } = e.currentTarget.dataset;
        wx.redirectTo({ url });
      },
      switchTab(e) {
        const { url } = e.currentTarget.dataset;
        wx.switchTab({ url });
      }
    }
  }
};
